home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / Effect library / Demo ƒ / Reversed wipes ƒ / Scissors reversed.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-11  |  3.2 KB  |  105 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        Scissors reversed.c
  4.  
  5. Purpose:    Graphic effect from offscreen bitmap to main window (on
  6.             screen).  See comments below for more description.
  7.  
  8.  
  9. MSG Demo -- graphic effects demonstration program
  10. Copyright (C) 1992-4 Mark Pilgrim & Dave Blumenthal
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "msg timing.h"
  30.  
  31. #define CorrectTime 3
  32. #define theWindowWidth (boundsRect.right-boundsRect.left)
  33. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  34.  
  35. pascal short ScissorsReversed(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect);
  36.  
  37. /* A region in two parts, starting at the middle of the bottom side and working
  38.    toward the bottom corners, then up the left and right sides. */
  39.    
  40. pascal short ScissorsReversed(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect)
  41. {
  42.     RgnHandle    curregion;
  43.     int            cx,gap,lastx,lasty;
  44.     int            BlockSize;
  45.     
  46.     BlockSize=theWindowHeight/25;
  47.     cx = theWindowWidth / 2;
  48.  
  49.     curregion=NewRgn();
  50.     lastx=theWindowWidth/2;
  51.     gap=theWindowWidth/2+BlockSize;
  52.     do
  53.     {
  54.         StartTiming();
  55.         SetEmptyRgn(curregion);
  56.         MoveTo(cx,0);
  57.         OpenRgn();
  58.             LineTo(lastx,theWindowHeight);        /* get the right half on bottom side */
  59.             LineTo(gap,theWindowHeight);
  60.             LineTo(cx,0);
  61.             LineTo(theWindowWidth-lastx,theWindowHeight);    /* left 1/2 on bottom */
  62.             LineTo(theWindowWidth-gap,theWindowHeight);
  63.             LineTo(cx,0);
  64.         CloseRgn(curregion);
  65.         OffsetRgn(curregion, boundsRect.left, boundsRect.top);
  66.         CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  67.             &boundsRect, &boundsRect, 0, curregion);
  68.         lastx=gap;
  69.         gap+=BlockSize;
  70.         TimeCorrection(CorrectTime);
  71.     }
  72.     while (gap<=theWindowWidth+BlockSize);
  73.     
  74.     gap=theWindowHeight-BlockSize;
  75.     lasty=theWindowHeight;
  76.     do
  77.     {
  78.         StartTiming();
  79.         SetEmptyRgn(curregion);
  80.         MoveTo(cx,0);
  81.         OpenRgn();
  82.             LineTo(theWindowWidth,lasty);   /* get the right half */
  83.             LineTo(theWindowWidth,gap);
  84.             LineTo(cx,0);
  85.             LineTo(0,lasty);                   /* get the left half */
  86.             LineTo(0,gap);
  87.             LineTo(cx,0);
  88.         CloseRgn(curregion);
  89.         OffsetRgn(curregion, boundsRect.left, boundsRect.top);
  90.         CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  91.             &boundsRect, &boundsRect, 0, curregion);
  92.         lasty=gap;
  93.         gap-=BlockSize;
  94.         TimeCorrection(CorrectTime);
  95.     }
  96.     while (gap>=0);
  97.     
  98.     CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  99.         &boundsRect, &boundsRect, 0, 0L);        /* if we missed any bits */
  100.     
  101.     DisposeRgn(curregion);
  102.     
  103.     return 0;
  104. }
  105.